package net.eicp.jxcontent.cms.snippet

import net.eicp.jxcontent.core.snippet.JXDispatchSnippet
import net.liftweb.common._
import net.liftweb.http._
import net.liftweb.http.S._
import net.liftweb.util._
import net.liftweb.util.Helpers._
import net.liftweb.mapper._
import scala.xml._
import com.mongodb.casbah.Imports._
import com.mongodb.casbah.commons.MongoDBObject
import com.mongodb.casbah.query.dsl.FluidQueryOperators
import net.eicp.jxcontent.core.snippet.JXSnippetScope

class FormRender2 extends JXDispatchSnippet with Logger {
  override def dispatch = { case "render2" => render2 _ }
  
  object value1 extends RequestVar("初始化1")
  
  def render2(scope: JXSnippetScope) = {
      10 === { xhtml =>
        "@text1" #> SHtml.text(value1.get, value => {
          value1(value)
          val b = DBObject("name" -> value)
          scope.saveOrUpdate({case ("JXForm", a: DBObject) => (("JXForm", a ++ b))})(("JXForm", b))
        }) apply xhtml
      }
  }
}